/*
 * @Description:各种信息混入
 * @Author: wangfuwei
 * @Date: 2020-11-30 17:56:48
 * @LastEditors: wangfuwei
 * @LastEditTime: 2020-12-08 00:22:18
 * @FilePath: /horizon-frontend/src/utils/mixin.js
 */

import { mapGetters } from "vuex";
import { deviceEnquire } from "@/utils/device";
import { DEVICE } from "@/store/mutation-types";
import getters from "@/store/getters";

/**
 * 系统基本信息
 */
const appMixin = {
  computed: {
    ...mapGetters(Object.keys(getters)),
  },
};

/**
 * 初始化登录设备信息
 * 一般在入口文件(App.vue)混入
 */
const appDeviceEnquire = {
  mounted() {
    const { $store } = this;
    deviceEnquire(deviceType => {
      $store.commit(`app/${DEVICE}`, deviceType);
    });
  },
};

export { appMixin, appDeviceEnquire };
